package com.financing.wap.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.financing.wap.common.SqlName;
import com.financing.wap.dao.IMessageDao;
import com.financing.wap.dto.MessageDTO;
import com.financing.wap.dto.MessageMailDTO;
import com.financing.wap.dto.MessageSmsDTO;
import com.financing.wap.vo.MessageVO;


@Repository("messageDao")
@SuppressWarnings(value={"unchecked", "deprecation"})
public class MessageDaoImpl extends BaseDaoImpl<MessageDTO, java.lang.Integer> implements IMessageDao {

	@Override
	public List<MessageDTO> getMessageList(MessageVO msg) {
		List<MessageDTO> result = this.getSqlMapClientTemplate().queryForList(SqlName.MESSAGE_LIST,msg);
		return result;
	}

	@Override
	public Class<MessageDTO> getEntityClass() {

		return MessageDTO.class;
	}

	@Override
	public MessageDTO getMessageView(Map<String,Object> paramsMap) {
		MessageDTO result = (MessageDTO)this.getSqlMapClientTemplate().queryForObject(SqlName.MESSAGE_VIEW,paramsMap);
		
		return result;
	}
	@Override
	public int updateMessageStatus(MessageDTO dto) {
		this.getSqlMapClientTemplate().update(SqlName.UPDATE_MESSAGE_STATUS,dto);
		return dto.getId();
	}

	@Override
	public Integer getMessageCount(MessageVO msg) {
		
		Integer count = (Integer)this.getSqlMapClientTemplate().queryForObject(SqlName.MESSAGE_LIST_COUNT,msg);
		return count;
	}

	@Override
	public int insertMailInfo(MessageMailDTO mail) {
		Integer count = (Integer)this.getSqlMapClientTemplate().insert(SqlName.MESSAGE_MAIL_INSERT,mail);
		return count;
	}

	@Override
	public int addMessageSms(MessageSmsDTO messageSmsDTO) {
		return (Integer)this.getSqlMapClientTemplate().insert(SqlName.MESSAGE_SMS_INSERT,messageSmsDTO);
	}

	
}
